package clases;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;
import clases.Base;

public class ServicioWebCom extends Base 
{
private static final String SOAP_ACTION = "http://tempuri.org/";
	
    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String Dirs = Base.WebServer + "OrdenesVentaMovil.asmx";
    private static final String Dir = Base.WebServer + "carretillamovil.asmx";
   
    
    static Boolean Respuesta = false;
    static String Resp = "";
    
    public static Boolean ValidarUsuario(String METHOD_NAME, String Usuario, String Password, String Device, String Mensaje)
    {
    	Respuesta = false;    	
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Dispositivo", Device);            
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;                        
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {            	
            	Respuesta = true;
            }
            else
            {
            	Respuesta = false;
            }
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;        	
        }
        return Respuesta;
    }
    
    public static Boolean CambiarPwd(String METHOD_NAME, String Usuario, String Password, String Device, String PasN, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("dispositivo", Device);
            request.addProperty("NuevoPwd", PasN);            
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static String BuscaArt(String METHOD_NAME, String Usuario, String Password, String Device, String Filtro, String Cat, String Cadena, String Mensaje)
    {
    	String Cad = "";    	
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Dispositivo", Device);
            request.addProperty("Filtro", Filtro);
            request.addProperty("Categoria", Cat);
            request.addProperty("LDatos", Cadena); 
            request.addProperty("Mensaje", Mensaje); 
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Cad = result.getProperty(1).toString();            	
            }
            else
            {
            	Cad = result.getProperty(1).toString();            	
            }
        }
        catch (Exception e) 
        {        	
        	Cad = "";        	
        }
        return Cad;
    }
    
    public static String Categorias(String METHOD_NAME, String Usuario, String Password, String Device, String Cadena, String Mensaje)
    {
    	String Cad = "";    	
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Device", Device);            
            request.addProperty("Cadena", Cadena);
            request.addProperty("Mensaje", "");
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Cad = result.getProperty(1).toString();            	
            }
        }
        catch (Exception e) 
        {        	
        	Cad = "";        	
        }
        return Cad;
    }
    
    public static Boolean AddCarretillas(String METHOD_NAME, String Usuario, String Password, String Device, String Sku, int Cant, double precio, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Device", Device);            
            request.addProperty("SKU", Sku);
            request.addProperty("Precio", precio);
            request.addProperty("Cantidad", Cant);
            request.addProperty("Mensaje", Mensaje);
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean ModCarretillas(String METHOD_NAME, String Usuario, String Password, String Device, String Sku, int Cant, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Device", Device);            
            request.addProperty("SKU", Sku);
            request.addProperty("Cantidad", Cant);
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static String Carretillas(String METHOD_NAME, String Usuario, String Password, String Device, String Cadena, String Mensaje)
    {
    	String Cad = "";
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);            
            request.addProperty("Device", Device);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("Cadena", Cadena);            
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dir);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Cad = result.getProperty(2).toString();
            	Log.e("devuelve", Cad);
            }
            else
            {
            	Log.e("No devuelve", "Carretilla");
            }
        }
        catch (Exception e) 
        {        	
        	Cad = "";
        	Log.e("No devuelve catch", e.getMessage());
        }
        return Cad;
    }
    
    public static Boolean FechaAct(String METHOD_NAME, String Usuario, String Password, String HH, String Bateria, String Version, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);            
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean Autorizar(String METHOD_NAME, String Usuario, String Password, String Documento, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Documento", Documento);
            request.addProperty("Mensaje", Mensaje);                        
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean ListaCliente(String METHOD_NAME, String Usuario, String Password, String Cliente, String Mensaje, String Listado, String Filtro, int Tope)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Cliente", Cliente);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("Listado", Listado);
            request.addProperty("Filtro", Filtro);
            request.addProperty("Tope", Tope);
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean ListaCliente2(String METHOD_NAME, String Usuario, String Password, String Cliente, String Mensaje, String Listado, String Filtro, int Tope)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Cliente", Cliente);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("Listado", Listado);
            request.addProperty("Filtro", Filtro);
            request.addProperty("Tope", Tope);
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean ListaClienteUsr(String METHOD_NAME, String Usuario, String Password, String Cliente, String Mensaje, String Listado, String Filtro, int Tope)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Cliente", Cliente);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("Listado", Listado);
            request.addProperty("Filtro", Filtro);
            request.addProperty("Tope", Tope);
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean DatosPag(String METHOD_NAME, String Usuario, String Password, String Documento, String LDatos, String Mensaje)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Documento", Documento);
            request.addProperty("LDatos", LDatos);
            request.addProperty("Mensaje", Mensaje);                       
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
    
    public static Boolean InformacionDespacho(String METHOD_NAME, String Usuario, String Password, String Orden, String Mensaje, String Listado)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Orden", Orden);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("LDatos", Listado);                                   
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }    
    public static Boolean Detalle(String METHOD_NAME, String Usuario, String Password, String Orden, String Mensaje, String Listado)
    {
    	Respuesta = false;
        try
        {
            SoapObject request = new SoapObject(NAMESPACE + "WSShowRooms/Clientes", METHOD_NAME);
            request.addProperty("Usuario", Usuario);
            request.addProperty("Password", Password);
            request.addProperty("Orden", Orden);
            request.addProperty("Mensaje", Mensaje);
            request.addProperty("LDatos", Listado);                                   
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(Dirs);

            androidHttpTransport.call(SOAP_ACTION + "WSShowRooms/Clientes/" + METHOD_NAME, envelope);            
            SoapObject result = (SoapObject)envelope.bodyIn;            
            if(result.getProperty(0).toString().compareToIgnoreCase("TRUE") == 0)
            {
            	Respuesta = true;
            }          
        }
        catch (Exception e) 
        {        	
        	Respuesta = false;
        }
        return Respuesta;
    }
}